package com.liyongjian.page.api;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.liyongjian.page.dto.AjaxResponse;
import com.liyongjian.page.mvc.BaseController;
import com.liyongjian.page.service.VisitService;


@Controller
@RequestMapping("api/visit")
public class VisitController extends BaseController {

    @Autowired
    private VisitService visitService;


    @ResponseBody
    @RequestMapping(path = "page", method = RequestMethod.POST)
    public AjaxResponse sys(@RequestBody Map<String, Object> obj, HttpServletRequest request,
            HttpServletResponse response, ModelMap model) {
        AjaxResponse ajax = new AjaxResponse(true);
        String token = (String) obj.get("token");
        Long sysId = Long.valueOf(obj.get("sysId").toString());
        String platform = (String) obj.get("platform");
        String path = (String) obj.get("path");
        Integer count = obj.containsKey("count") ? Integer.valueOf(obj.get("count").toString()) : 1;
        Map<String, Object> param = (Map<String, Object>) obj.get("param");
        visitService.page(token, sysId, platform, path, count, param);
        return ajax;
    }



}
